package com.wzh.advancelog.log.db;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.wzh.advancelog.log.WzhLog;

/**
 * @author: zhwang37
 * @date: 2021/8/30 19:46
 * @email:zhwang37@iflytek.com
 * @describe:
 */
@Database(entities = {LogEntity.class}, version = 1)
public abstract class MyDatabase extends RoomDatabase {
    private static final String DATABASE_NAME = "my_db";
    private static MyDatabase databaseInstance;

    public static synchronized MyDatabase getInstance() {
        if (databaseInstance == null) {
            databaseInstance = Room
                    .databaseBuilder(WzhLog.getGlobalContext(), MyDatabase.class, DATABASE_NAME)
                    .build();
        }
        return databaseInstance;
    }

    public abstract LogDao logDao();
}
